from flask import Flask, render_template, request, session, redirect, url_for

app = Flask(__name__)


@app.route('/')
def index():  # put application's code here
    user = session.get('user')

    if user:
        return render_template('index.html', msg='欢迎光临！',
                               link_url='/stu', link_text='学生信息管理')
    return render_template('index.html', msg='你还没有登录', link_url='/login', link_text='点击登录')


# <editor-fold desc="用户登录">
@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'GET':
        return render_template('login.html')
    return render_template('index.html')


@app.route('/stu')
def stu():
    return render_template('students.html')


# </editor-fold>


if __name__ == '__main__':
    app.run()
